#include "PositionPair.hpp"

PositionPair::PositionPair(const Position& src, const Position& dst)
	: src(src), dst(dst)
{
	unsigned char src_x;
	unsigned char src_y;
	unsigned char dst_x;
	unsigned char dst_y;
	
	hash_key = 0;
	
	src_x = (unsigned char) src.getRealX();
	src_y = (unsigned char) src.getRealY();
	dst_x = (unsigned char) dst.getRealX();
	dst_y = (unsigned char) dst.getRealY();
	
	hash_key |= (src_x & 0x0F);
	hash_key <<= 4;
	hash_key |= (src_y & 0x0F);
	hash_key <<= 4;
	hash_key |= (dst_x & 0x0F);
	hash_key <<= 4;
	hash_key |= (dst_y & 0x0F);	
}
		
PositionPair::~PositionPair()
{}
	
bool PositionPair::operator==(const PositionPair& ppair) const
{	return ((src == ppair.src) && (dst == ppair.dst));	}

bool PositionPair::operator!=(const PositionPair& ppair) const
{	return (!this->operator==(ppair));	}

unsigned short	PositionPair::getHashKey() const
{	return (hash_key);	}
